(function(angular) {
	"use strict";
	angular.module("fs.waf").controller("cls.popup.paySwift.swiftFileController", swiftFileController);
	swiftFileController.$inject = [ "$scope", "$uibModalInstance", "dialogsModule", "layoutConfig", "authService", "validatorConfig", "modalService" ];
	function swiftFileController($scope, $uibModalInstance, dialogsModule, layoutConfig, authService, validatorConfig, modalService) {
		var ctrl = this;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.swiftFile = {};

		ctrl.init = function() {
			if (ctrl.dialogsModule.params) {
				var paySwift = ctrl.dialogsModule.params.paySwift;
				authService.view(paySwift).then(function(response) {
					ctrl.swiftFile = response.data || ctrl.swiftFile;
				}, angular.noop);
			}
		};

		ctrl.coverMsgFileIdLink = function(paySwiftFile, from) {
			modalService.openCustomDialogs({
				"title" : "title.popup.view.swiftfile",
				"dialogsModule" : "cls.paySwift.swiftFile",
				"params" : {
					"paySwift" : {
						swiftFileId : paySwiftFile.coverMsgFileId
					}
				},
				"btnCallback" : {
					"ok" : function() {
					}
				}
			});
		};

		ctrl.ok = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback["ok"] || dialogsModule.btnCallback["ok"]() !== false) {
				$uibModalInstance.close();
			}
		};

		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback["close"] || dialogsModule.btnCallback["close"]() !== false) {
				$uibModalInstance.dismiss();
			}
		};

	}
})(angular);
